package com.cms.service.impl;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cms.base.Pagination;
import com.cms.dao.ChannelDao;
import com.cms.entity.Channel;
import com.cms.service.ChannelService;


@Service(value="channelService")
public class ChannelServiceImpl implements ChannelService {
	
	private ChannelDao channelDao;
	

	
	public Channel get(Serializable id) {
		return channelDao.find(id, Channel.class);
	}

	public void delete(Serializable id) {
		channelDao.delete(id, Channel.class);
	}

	public void save(Channel entity) {
		channelDao.save(entity);
	}

	public void update(Channel entity) {
		channelDao.update(entity);
	}

	
	public Pagination<Channel> queryAllChannels(Channel channel, int firstResult, int maxResults){
		return channelDao.queryAllChannels(channel, firstResult, maxResults);
	}
	
	public List<Channel> queryChannels(Channel channel){
		return channelDao.queryChannels(channel);
	}
	
	public void delete(List<Serializable> ids){
		List<Serializable> list = new ArrayList<Serializable>();
		for(int i=0; i<ids.size(); i++){
			Serializable id = ids.get(i);
			int d = Integer.parseInt(id.toString());
			list.add(d);
		}
		channelDao.delete(ids, Channel.class);
	}
	
	
	public ChannelDao getChannelDao() {
		return channelDao;
	}
	@Autowired
	public void setChannelDao(ChannelDao channelDao) {
		this.channelDao = channelDao;
	}
	
	
}
